import store from '../store'
import router from './index'
import { getCookie } from '../util'

export default () => {
    // setCookie('userToken', '21')
    let token = getCookie('userToken')
    store.commit('initToken', token)
    router.beforeEach((to, from, next) => {
        if (to.path !== '/loginInfo' && !token) {
            next({ path: '/loginInfo' })
            return
        }
        next()
    })
}
